<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="module">
    import Promise from "./index.js";
	{
		// const p = new Promise(function(){
		// });
		// console.log(p);// pending  undefined
    }

    // Promise的状态是可以更改的：
    // pending---->fulfilled
    // 1-调用resolve函数
	{
		// const p = new Promise(function(resolve){
		// 	resolve(100);// pending->fulfilled   undefined---->100
		// });
		// console.log(p);// fulfilled  100
    }

    // pending---->rejected
    // 1- 调用reject函数
	{
		// const p = new Promise(function(resolve,reject){
		// 	reject(200);// pending->rejected   undefined---->200
		// });
		// console.log(p);// rejected  200
    }
    // 2- 产生异常
	{
		const p = new Promise(function(resolve,reject){
			throw "异常";// pending--->rejected undefined--->异常
		});
		console.log(p);// rejected  异常
    }

</script>
</html>